namespace InventoryManagement
{
	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.ComponentModel;
	using System.Data;
	using System.Data.SqlClient;
	using System.Text;
	
	
	public class CheckList_Network : BaseTable
	{
		
		#region Static SQL String Members
		/// <remarks>This field represents the full SELECT string for the table CheckList Network, with the WHERE clause.</remarks>
		internal static string _SQL_Select = "SELECT [ID], [ID_Network], [Notes], [Date], [InventoryBy], [URLAttachment], [CheckListBy] FROM [dbo].[CheckList Network] WHERE [ID]=@ID ";
		
		/// <remarks>This field represents the full SELECT string for the table CheckList Network, with the WHERE clause.</remarks>
		internal static string _SQL_SelectByParam = @"SELECT [ID], [ID_Network], [Notes], [Date], [InventoryBy], [URLAttachment], [CheckListBy] FROM [dbo].[CheckList Network] WHERE isnull(convert(varchar(36),[ID]),'true')=isnull(convert(varchar(36),@ID),isnull(convert(varchar(36),[ID]),'true')) AND isnull(convert(varchar(36),[ID_Network]),'true')=isnull(convert(varchar(36),@ID_Network),isnull(convert(varchar(36),[ID_Network]),'true')) AND isnull(convert(varchar,[Notes]),'true')=isnull(convert(varchar,@Notes),isnull(convert(varchar,[Notes]),'true')) AND isnull(convert(varchar,[Date]),'true')=isnull(convert(varchar,@Date),isnull(convert(varchar,[Date]),'true')) AND isnull(convert(varchar,[InventoryBy]),'true')=isnull(convert(varchar,@InventoryBy),isnull(convert(varchar,[InventoryBy]),'true')) AND isnull(convert(varchar,[URLAttachment]),'true')=isnull(convert(varchar,@URLAttachment),isnull(convert(varchar,[URLAttachment]),'true')) AND isnull(convert(varchar,[CheckListBy]),'true')=isnull(convert(varchar,@CheckListBy),isnull(convert(varchar,[CheckListBy]),'true')) ";
		
		/// <remarks>This field represents the full INSERT INTO string for the table CheckList Network.</remarks>
		internal static string _SQL_Insert = "INSERT INTO [dbo].[CheckList Network] ([ID], [ID_Network], [Notes], [Date], [InventoryBy], [URLAttachment], [CheckListBy]) VALUES(@ID, @ID_Network, @Notes, @Date, @InventoryBy, @URLAttachment, @CheckListBy) ";
		
		/// <remarks>This field represents the full UPDATE string for the table CheckList Network, with the WHERE clause.</remarks>
		internal static string _SQL_Update = "UPDATE [dbo].[CheckList Network] SET [ID] = @ID, [ID_Network] = @ID_Network, [Notes] = @Notes, [Date] = @Date, [InventoryBy] = @InventoryBy, [URLAttachment] = @URLAttachment, [CheckListBy] = @CheckListBy WHERE [ID]=@ID ";
		
		/// <remarks>This field represents the DELETE string for the table CheckList Network, with the WHERE clause.</remarks>
		internal static string _SQL_Delete = "DELETE FROM [dbo].[CheckList Network] WHERE [ID]=@ID ";
		#endregion
		
		#region Tables Members
		/// <remarks>SQL Type:uniqueidentifier - </remarks>
		private System.Nullable<System.Guid> _ID;
		
		[DisplayName("ID")]
		[Category("Primary Key")]
		public System.Nullable<System.Guid> ID
		{
			get
			{
				try
				{
					return _ID;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting ID", err);
				}
			}
			set
			{
				try
				{
					_ID = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting ID", err);
				}
			}
		}
		
		/// <remarks>SQL Type:uniqueidentifier - </remarks>
		private System.Nullable<System.Guid> _ID_Network;
		
		[DisplayName("ID_Network")]
		[Category("Foreign Key")]
		public System.Nullable<System.Guid> ID_Network
		{
			get
			{
				try
				{
					return _ID_Network;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting ID_Network", err);
				}
			}
			set
			{
				try
				{
					_ID_Network = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting ID_Network", err);
				}
			}
		}
		
		/// <remarks>SQL Type:varchar - </remarks>
		private string _Notes;
		
		[DisplayName("Notes")]
		[Category("Column")]
		public string Notes
		{
			get
			{
				try
				{
					return _Notes;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Notes", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 1000))
					{
						_Notes = value;
					}
					else
					{
						throw new OverflowException("Error setting Notes, Length of value is to long. Maximum Length: 1000");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Notes", err);
				}
			}
		}
		
		/// <remarks>SQL Type:datetime - </remarks>
		private System.Nullable<System.DateTime> _Date;
		
		[DisplayName("Date")]
		[Category("Column")]
		public System.Nullable<System.DateTime> Date
		{
			get
			{
				try
				{
					return _Date;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting Date", err);
				}
			}
			set
			{
				try
				{
					_Date = value;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting Date", err);
				}
			}
		}
		
		/// <remarks>SQL Type:varchar - </remarks>
		private string _InventoryBy;
		
		[DisplayName("Inventory By")]
		[Category("Column")]
		public string InventoryBy
		{
			get
			{
				try
				{
					return _InventoryBy;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting InventoryBy", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 200))
					{
						_InventoryBy = value;
					}
					else
					{
						throw new OverflowException("Error setting InventoryBy, Length of value is to long. Maximum Length: 200");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting InventoryBy", err);
				}
			}
		}
		
		/// <remarks>SQL Type:varchar - </remarks>
		private string _URLAttachment;
		
		[DisplayName("URLAttachment")]
		[Category("Column")]
		public string URLAttachment
		{
			get
			{
				try
				{
					return _URLAttachment;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting URLAttachment", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 400))
					{
						_URLAttachment = value;
					}
					else
					{
						throw new OverflowException("Error setting URLAttachment, Length of value is to long. Maximum Length: 400");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting URLAttachment", err);
				}
			}
		}
		
		/// <remarks>SQL Type:varchar - </remarks>
		private string _CheckListBy;
		
		[DisplayName("Check List By")]
		[Category("Column")]
		public string CheckListBy
		{
			get
			{
				try
				{
					return _CheckListBy;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting CheckListBy", err);
				}
			}
			set
			{
				try
				{
					if ((value.Length <= 200))
					{
						_CheckListBy = value;
					}
					else
					{
						throw new OverflowException("Error setting CheckListBy, Length of value is to long. Maximum Length: 200");
					}
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting CheckListBy", err);
				}
			}
		}
		#endregion
		
		#region Related Objects
		/// <remarks>Represents the foreign key object</remarks>
		private Inventory_Network _ID_Network_Inventory_Network;
		
		[Description("Represents the foreign key object of the type Inventory_Network")]
		public Inventory_Network ID_Network_Inventory_Network
		{
			get
			{
				try
				{
					return _ID_Network_Inventory_Network;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error getting ID_Network_Inventory_Network", err);
				}
			}
			set
			{
				try
				{
					_ID_Network_Inventory_Network = value;
					_ID_Network = _ID_Network_Inventory_Network.ID;
				}
				catch (System.Exception err)
				{
					throw new Exception("Error setting ID_Network_Inventory_Network", err);
				}
			}
		}
		#endregion
		
		#region Public Methods
		public void Select()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = CheckList_Network._SQL_Select;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				SqlDataReader rs = Com.ExecuteReader();
				while(rs.Read())
				{
					AddFromRecordSet(rs);
				}
				rs.Close();
				Conn.Close();
				rs.Dispose();
				Com.Dispose();
				Conn.Dispose();
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public System.Data.DataTable SelectByParam()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = CheckList_Network._SQL_SelectByParam;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				SqlDataAdapter objDataAdapter = new SqlDataAdapter(Com);
				DataTable objDataTable = new DataTable();
				objDataAdapter.Fill(objDataTable);
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return objDataTable;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Insert()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = CheckList_Network._SQL_Insert;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Update()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = CheckList_Network._SQL_Update;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public int Delete()
		{
			try
			{
				SqlConnection Conn = new SqlConnection(_connString);
				SqlCommand Com = Conn.CreateCommand();
				Com.CommandText = CheckList_Network._SQL_Delete;
				Com.Parameters.AddRange(GetSqlParameters());
				Conn.Open();
				int rowseffected = Com.ExecuteNonQuery();
				Conn.Close();
				Com.Dispose();
				Conn.Dispose();
				return rowseffected;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		
		public string[] GetSqlCommandStrings()
		{
			try
			{
				string[] CommStr = new string[4];
				CommStr[0] = "SELECT [ID], [ID_Network], [Notes], [Date], [InventoryBy], [URLAttachment], [CheckListBy] FROM [dbo].[CheckList Network] WHERE [ID] = " + _ID + "";
				CommStr[1] = "INSERT INTO [dbo].[CheckList Network] ([ID], [ID_Network], [Notes], [Date], [InventoryBy], [URLAttachment], [CheckListBy]) VALUES(" + _ID + ", " + _ID_Network + ", '" + _Notes.Replace("'","''") + "', '" + _Date + "', '" + _InventoryBy.Replace("'","''") + "', '" + _URLAttachment.Replace("'","''") + "', '" + _CheckListBy.Replace("'","''") + "')";
				CommStr[2] = "UPDATE [dbo].[CheckList Network] SET [ID_Network] = " + _ID_Network + " ,[Notes] = '" + _Notes.Replace("'","''") + "' ,[Date] = '" + _Date + "' ,[InventoryBy] = '" + _InventoryBy.Replace("'","''") + "' ,[URLAttachment] = '" + _URLAttachment.Replace("'","''") + "' ,[CheckListBy] = '" + _CheckListBy.Replace("'","''") + "' WHERE [ID] = " + _ID + "";
				CommStr[3] = "DELETE FROM [dbo].[CheckList Network] WHERE [ID] = " + _ID + "";
				return CommStr;
			}
			catch (System.Exception )
			{
				throw;
			}
		}
		#endregion
		
		#region Private Methods
		private void AddFromRecordSet(SqlDataReader rs)
		{
			try
			{
				// if value from the recordset, to the ID field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("ID")) == false))
				{
					ID = rs.GetGuid(rs.GetOrdinal("ID"));
				}
				// if value from the recordset, to the ID_Network field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("ID_Network")) == false))
				{
					ID_Network = rs.GetGuid(rs.GetOrdinal("ID_Network"));
				}
				// if value from the recordset, to the Notes field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Notes")) == false))
				{
					Notes = rs.GetString(rs.GetOrdinal("Notes"));
				}
				// if value from the recordset, to the Date field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("Date")) == false))
				{
					Date = rs.GetDateTime(rs.GetOrdinal("Date"));
				}
				// if value from the recordset, to the InventoryBy field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("InventoryBy")) == false))
				{
					InventoryBy = rs.GetString(rs.GetOrdinal("InventoryBy"));
				}
				// if value from the recordset, to the URLAttachment field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("URLAttachment")) == false))
				{
					URLAttachment = rs.GetString(rs.GetOrdinal("URLAttachment"));
				}
				// if value from the recordset, to the CheckListBy field is NOT null then set the value.
				if ((rs.IsDBNull(rs.GetOrdinal("CheckListBy")) == false))
				{
					CheckListBy = rs.GetString(rs.GetOrdinal("CheckListBy"));
				}
			}
			catch (SqlException sqlExc)
			{
				throw sqlExc;
			}
			catch (Exception Exc)
			{
				throw Exc;
			}
		}
		
		private SqlParameter[] GetSqlParameters()
		{
			List<SqlParameter> SqlParmColl = new List<SqlParameter>();
			try
			{
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@ID", ID, SqlDbType.UniqueIdentifier));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@ID_Network", ID_Network, SqlDbType.UniqueIdentifier));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@Notes", Notes, SqlDbType.VarChar));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@Date", Date, SqlDbType.DateTime));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@InventoryBy", InventoryBy, SqlDbType.VarChar));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@URLAttachment", URLAttachment, SqlDbType.VarChar));
				SqlParmColl.Add(InventoryManagement.AddSqlParm("@CheckListBy", CheckListBy, SqlDbType.VarChar));
				return SqlParmColl.ToArray();
			}
			catch (Exception Exc)
			{
				throw Exc;
			}
		}
		#endregion
	}
	
	public class CheckList_NetworkCollection : System.Collections.CollectionBase
	{
		
		[Description("Adds a new CheckList_Network to the collection.")]
		public int Add(CheckList_Network item)
		{
			int newindex = List.Add(item);
			return newindex;
		}
		
		[Description("Removes a CheckList_Network from the collection.")]
		public void Remove(CheckList_Network item)
		{
			List.Remove(item);
		}
		
		[Description("Inserts an CheckList_Network into the collection at the specified index.")]
		public void Insert(int index, CheckList_Network item)
		{
			List.Insert(index, item);
		}
		
		[Description("Returns the index value of the CheckList_Network class in the collection.")]
		public int IndexOf(CheckList_Network item)
		{
			return List.IndexOf(item);
		}
		
		[Description("Returns true if the CheckList_Network class is present in the collection.")]
		public bool Contains(CheckList_Network item)
		{
			return List.Contains(item);
		}
	}
	
	public enum CheckList_Network_Fields
	{
		
		ID,
		
		ID_Network,
		
		Notes,
		
		Date,
		
		InventoryBy,
		
		URLAttachment,
		
		CheckListBy,
	}
}
